package pl.vojna.ant_alg.tests;

import java.io.File;

import pl.vojna.ant_alg.Problem;
import pl.vojna.ant_alg.Utils;
import pl.vojna.ant_alg.algorithms.RandomSearch;
import pl.vojna.ant_alg.lokal_search_alg.TabuSearch;

public class RandomAndTabu {
	/**
	 * Testy pochodza z QAPlib, korzystam z ich oznaczen.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		runTest("chr12a", 9552, "opt, 100k+50k");
		runTest("chr12b", 9742, "opt, 100k+50k");
		runTest("chr12c", 11156, "opt, 100k+50k");
		runTest("chr15a", 9896, "opt, 100k+50k");
		runTest("chr15b", 7990, "opt, 100k+50k");
		runTest("chr15c", 9504, "opt, 100k+50k");
		runTest("chr18a", 11098, "opt, 100k+50k");
		runTest("chr18b", 1534, "opt, 100k+50k");
		runTest("chr20a", 2192, "opt, 100k+50k");
		runTest("chr20b", 2298, "opt, 100k+50k");
		runTest("chr20c", 14142, "opt, 100k+50k");
         
	}

	private static void runTest(String filename, int bestSolution,
			String description) {
		Problem p = new Problem(new File("data/" + filename + ".dat"));
		int[] s = new RandomSearch().solve(p, 0, false, 100000);
		s = new TabuSearch().improve(s, p, 50000);
		Utils.showSolution(s);
		Utils.p("Random+TabuSearch", filename, Utils.solutionCost(p, s),
				bestSolution + " " + description);
	}

}
